<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    

    <title>SpringBoot通过JPA链接数据库及配置文件相关 | 竹隐江南的博客</title>
    <meta name="author" content="dzy20@qq.com">
    
    <meta name="description" content="SpringBoot通过JPA链接数据库及配置文件相关">
    
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <meta property="og:title" content="SpringBoot通过JPA链接数据库及配置文件相关"/>
    <meta property="og:site_name" content="必须有人浴血奋战，世上才有自由可言！"/>

    
    <meta property="og:image" content="undefined"/>
    

    <link rel="icon" type="image/png" href="/favicon.png">
    <link rel="alternate" href="/atom.xml" title="必须有人浴血奋战，世上才有自由可言！" type="application/atom+xml">
    <link rel="stylesheet" href="/css/lib/materialize.min.css">
    <link rel="stylesheet" href="/css/lib/font-awesome.min.css">
    <link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">

    
        <link rel="stylesheet" href="/css/lib/prettify-tomorrow-night-eighties.css" type="text/css">
    
    <!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>


<body>
    <img src="/weixin_favicon.png" style="position: absolute; left: -9999px; opacity: 0; filter: alpha(opacity=0);">

    <nav class="green">
    <div class="nav-wrapper">
        <a href="#" data-activates="main-menu" class="button-collapse">
            <i class="fa fa-navicon"></i>
        </a>
        <div class="">
            <a href="/" class="brand-logo hide-on-med-and-down">必须有人浴血奋战，世上才有自由可言！</a>
            <ul class="right hide-on-med-and-down">
                
                    <li>
                        <a class="menu-home " href="/" >
                            <i class="fa fa-home "></i>
                            
                            首页
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-archive " href="/archives" >
                            <i class="fa fa-archive "></i>
                            
                            归档
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-category category-menu" href="javascript:;" data-activates="category-menu" >
                            <i class="fa fa-bookmark "></i>
                            
                            分类
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-reading " href="/reading" >
                            <i class="fa fa-book "></i>
                            
                            读书
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-about " href="/about" >
                            <i class="fa fa-user "></i>
                            
                            关于
                        </a>
                    </li>
                
                    <li>
                        <a class="menu-search modal-trigger " href="#search" >
                            <i class="fa fa-search "></i>
                            
                            搜索
                        </a>
                    </li>
                
            </ul>
            <div>
    <ul class="side-nav green darken-1" id="main-menu">
        
        <li class="side-user">
            <div class="row">
                <div class="col s4 no-padding">
                    <img class="avatar-image circle responsive-img" src="https://static.oschina.net/uploads/user/728/1456911_100.jpg?t=1393495702000" alt="User Avatar">
                </div>
                <div class="info col s8 valign-wrapper no-padding">
                    <div class="valign">
                        <p class="name">竹隐江南</p>
                        <p class="desc">Java后端/技术宅</p>
                    </div>
                </div>
            </div>
        </li>
        

        
            <li class="no-padding">
                <a class="waves-effect menu-home " href="/" >
                    <i class="fa fa-home "></i>
                    
                    首页
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-archive " href="/archives" >
                    <i class="fa fa-archive "></i>
                    
                    归档
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-category category-menu" href="javascript:;" data-activates="category-menu" >
                    <i class="fa fa-bookmark "></i>
                    
                    分类
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-reading " href="/reading" >
                    <i class="fa fa-book "></i>
                    
                    读书
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-about " href="/about" >
                    <i class="fa fa-user "></i>
                    
                    关于
                </a>
            </li>
        
            <li class="no-padding">
                <a class="waves-effect menu-search modal-trigger " href="#search" >
                    <i class="fa fa-search "></i>
                    
                    搜索
                </a>
            </li>
        
    </ul>

    <ul class="side-nav green darken-1" id="category-menu">
    

            

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/hive/">
                    hive <span class="right">2 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/Docker/">
                    Docker <span class="right">10 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/操作系统/">
                    操作系统 <span class="right">7 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/系统架构/">
                    系统架构 <span class="right">2 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/DevOps-CI/">
                    DevOps-CI <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/SSL/">
                    SSL <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/springboot/">
                    springboot <span class="right">8 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-0" collapse-level="0">
                <a class="no-padding" href="/categories/Linux/">
                    Linux <span class="right">1 篇</span></a>
                </a>
            </li>

        

            <li class="collapse-level-1" collapse-level="1">
                <a class="no-padding" href="/categories/Linux/Tomcat/">
                    Tomcat <span class="right">1 篇</span></a>
                </a>
            </li>

        

    </ul>
</div>

        </div>
    </div>
</nav>

<div id="search" class="modal search-modal">
    <div class="row">
        <div class="input-field col s12">
              <input id="search-input" type="text">
              <label for="search-input">搜索</label>
        </div>

    </div>
    <div id="search-result" class="search-result col s12">

    </div>
</div>


    <main>
        <div class="container main-container">
    <nav class="page-nav hide-on-small-only">
    <div class="nav-wrapper green">
        <span class="breadcrumb">当前位置（分类目录）</span>
        
            
    
    
    <a class="breadcrumb" href="/categories/springboot/">springboot</a>


        

        
    </div>
</nav>

<article>
    <div class="card">
        <div class="card-content">
            

            <div class="article-title">
                
    
        <h1>SpringBoot通过JPA链接数据库及配置文件相关</h1>
    


            </div>
            <time class="red-link-context" datetime="2017-07-06T05:39:00.000Z"><a href="/2017/07/06/SpringBoot通过JPA链接数据库及配置文件相关/">2017-07-06</a></time>

            <span id="busuanzi_container_page_pv" class="read-times-container">
    <i class="fa fa-eye"></i>
    <span id="busuanzi_value_page_pv"></span>
</span>

            
    <div class="tags-row">
        
            <a href="/tags/springboot/" class="chip red lighten-1">springboot</a>
        
    </div>


            <div class="toc red-link-context hide-on-med-and-down">
    <ol class="section table-of-contents"><li class="section table-of-contents-item section table-of-contents-level-1"><a class="section table-of-contents-link" href="#这个小章节会通过一个小例子引出配置文件的说明"><span class="section table-of-contents-text">这个小章节会通过一个小例子引出配置文件的说明</span></a></li><li class="section table-of-contents-item section table-of-contents-level-1"><a class="section table-of-contents-link" href="#链接数据库"><span class="section table-of-contents-text">链接数据库</span></a></li><li class="section table-of-contents-item section table-of-contents-level-1"><a class="section table-of-contents-link" href="#简短的总结"><span class="section table-of-contents-text">简短的总结</span></a></li><li class="section table-of-contents-item section table-of-contents-level-1"><a class="section table-of-contents-link" href="#SpringBoot全部的配置信息"><span class="section table-of-contents-text">SpringBoot全部的配置信息</span></a></li></ol>
</div>


            <div class="entry red-link-context">
                <h1 id="这个小章节会通过一个小例子引出配置文件的说明"><a href="#这个小章节会通过一个小例子引出配置文件的说明" class="headerlink" title="这个小章节会通过一个小例子引出配置文件的说明"></a>这个小章节会通过一个小例子引出配置文件的说明</h1><blockquote>
<p>想通过这个章节来说一下配置文件，本来想直接贴属性对比的，觉得不人道，就加了个小例子，配置文件说明会在最后贴出</p>
</blockquote>
<a id="more"></a>
<h1 id="链接数据库"><a href="#链接数据库" class="headerlink" title="链接数据库"></a>链接数据库</h1><p>Spring Boot链接数据库非常简单，自己默认使用的tomcat的pool，为了快速方便的展示，我这使用JPA进行操作，我并熟悉JPA，但是写个例子还是可以的，后续的章节会用mybaties</p>
<p>数据库依赖</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;!-- mysql --&gt;</div><div class="line">       &lt;dependency&gt;</div><div class="line">           &lt;groupId&gt;mysql&lt;/groupId&gt;</div><div class="line">           &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</div><div class="line">           &lt;version&gt;5.1.32&lt;/version&gt;</div><div class="line">       &lt;/dependency&gt;</div><div class="line">       &lt;!-- jpa --&gt;</div><div class="line">       &lt;dependency&gt;</div><div class="line">           &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">           &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;</div><div class="line">       &lt;/dependency&gt;</div></pre></td></tr></table></figure>
<p>创建一个用户对象,去除了get/set需要自己加哦。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">[@Entity](https://my.oschina.net/u/1260961)</div><div class="line">@Table(name = &quot;user&quot;)</div><div class="line">public class User implements Serializable &#123;</div><div class="line"></div><div class="line">    private static final long serialVersionUID = 1614429926091283866L;</div><div class="line"></div><div class="line">    @Id</div><div class="line">    @GeneratedValue(strategy = GenerationType.IDENTITY)</div><div class="line">    private Long id;</div><div class="line"></div><div class="line">    private String userName;</div><div class="line"></div><div class="line">    @DateTimeFormat(pattern = &quot;yyyy-MM-dd HH:mm:ss&quot;)</div><div class="line">    private Date  createDate;</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>写一个Dao接口</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">       @Repository</div><div class="line">public interface UserRepository extends JpaRepository&lt;User,Long&gt; &#123;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>写一个Controller</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">@RestController</div><div class="line">public class UserCtrl &#123;</div><div class="line"></div><div class="line">    @Autowired</div><div class="line">    UserRepository userRepository;</div><div class="line"></div><div class="line">    @RequestMapping(value = &quot;/inseruser&quot;)</div><div class="line">    public User insertUser()&#123;</div><div class="line">        User user = new User();</div><div class="line">        user.setUserName(&quot;user&quot;);</div><div class="line">        user.setCreateDate(new Date());</div><div class="line">        return userRepository.save(user);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>写JPA管理类</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">       @Order(Ordered.HIGHEST_PRECEDENCE)</div><div class="line">@Configuration</div><div class="line">@EnableTransactionManagement(proxyTargetClass = true)</div><div class="line">@EnableJpaRepositories(basePackages = &quot;com.dzy.**.dao&quot;)</div><div class="line">@EntityScan(basePackages = &quot;com.dzy.**.model&quot;)</div><div class="line">public class JpaConfigure &#123;</div><div class="line"></div><div class="line">    @Bean</div><div class="line">    PersistenceAnnotationBeanPostProcessor persistenceAnnotationBeanPostProcessor()&#123;</div><div class="line">        return new PersistenceAnnotationBeanPostProcessor();</div><div class="line">    &#125;</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>配置文件SpringBoot配置文件可以使用传统的properties，也可以使用yml，如下就是yml</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">spring:</div><div class="line">  datasource:</div><div class="line">url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&amp;autoReconnect=true&amp;characterEncoding=utf8</div><div class="line">username: root</div><div class="line">password: root</div><div class="line">  jpa:</div><div class="line">database: mysql</div><div class="line">show-sql: true</div><div class="line">hibernate:</div><div class="line">  ddl-auto: update</div><div class="line">  naming:</div><div class="line">strategy: org.hibernate.cfg.ImprovedNamingStrategy</div><div class="line">properties:</div><div class="line">  hibernate:</div><div class="line">dialect: org.hibernate.dialect.MySQL5Dialect</div></pre></td></tr></table></figure>
<p>这个时候可以启动工程，然后通过浏览器访问请求，请求成功<br><img src="https://static.oschina.net/uploads/img/201701/06153812_5c6y.jpg" alt="输入图片说明" title="在这里输入图片标题"></p>
<h1 id="简短的总结"><a href="#简短的总结" class="headerlink" title="简短的总结"></a>简短的总结</h1><p>上面是JPA链接数据库的简单列子，配置文件也是很简洁，SpringBoot的配置文件非常详细，文章最后会有一个比较全的配置文件方便大家搜索。<br>另外除了这篇之外，博主都会使用mybatis进行讲解，JPA仅仅在这个章节简单说明一下链接数据的配置，而且没有用连接池，后续都会有追加。</p>
<h1 id="SpringBoot全部的配置信息"><a href="#SpringBoot全部的配置信息" class="headerlink" title="SpringBoot全部的配置信息"></a>SpringBoot全部的配置信息</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div><div class="line">203</div><div class="line">204</div><div class="line">205</div><div class="line">206</div><div class="line">207</div><div class="line">208</div><div class="line">209</div><div class="line">210</div><div class="line">211</div><div class="line">212</div><div class="line">213</div><div class="line">214</div><div class="line">215</div><div class="line">216</div><div class="line">217</div><div class="line">218</div><div class="line">219</div><div class="line">220</div><div class="line">221</div><div class="line">222</div><div class="line">223</div><div class="line">224</div><div class="line">225</div><div class="line">226</div><div class="line">227</div><div class="line">228</div><div class="line">229</div><div class="line">230</div><div class="line">231</div><div class="line">232</div><div class="line">233</div><div class="line">234</div><div class="line">235</div><div class="line">236</div><div class="line">237</div><div class="line">238</div><div class="line">239</div><div class="line">240</div><div class="line">241</div><div class="line">242</div><div class="line">243</div><div class="line">244</div><div class="line">245</div><div class="line">246</div><div class="line">247</div><div class="line">248</div><div class="line">249</div><div class="line">250</div><div class="line">251</div><div class="line">252</div><div class="line">253</div><div class="line">254</div><div class="line">255</div><div class="line">256</div><div class="line">257</div><div class="line">258</div><div class="line">259</div><div class="line">260</div><div class="line">261</div><div class="line">262</div><div class="line">263</div><div class="line">264</div><div class="line">265</div><div class="line">266</div><div class="line">267</div><div class="line">268</div><div class="line">269</div><div class="line">270</div><div class="line">271</div><div class="line">272</div><div class="line">273</div><div class="line">274</div><div class="line">275</div><div class="line">276</div><div class="line">277</div><div class="line">278</div><div class="line">279</div><div class="line">280</div><div class="line">281</div><div class="line">282</div><div class="line">283</div><div class="line">284</div><div class="line">285</div><div class="line">286</div><div class="line">287</div><div class="line">288</div><div class="line">289</div><div class="line">290</div><div class="line">291</div><div class="line">292</div><div class="line">293</div><div class="line">294</div><div class="line">295</div><div class="line">296</div><div class="line">297</div><div class="line">298</div><div class="line">299</div><div class="line">300</div><div class="line">301</div><div class="line">302</div><div class="line">303</div><div class="line">304</div><div class="line">305</div><div class="line">306</div><div class="line">307</div><div class="line">308</div><div class="line">309</div><div class="line">310</div><div class="line">311</div><div class="line">312</div><div class="line">313</div><div class="line">314</div><div class="line">315</div><div class="line">316</div><div class="line">317</div><div class="line">318</div><div class="line">319</div><div class="line">320</div><div class="line">321</div><div class="line">322</div><div class="line">323</div><div class="line">324</div><div class="line">325</div><div class="line">326</div><div class="line">327</div><div class="line">328</div><div class="line">329</div><div class="line">330</div><div class="line">331</div><div class="line">332</div><div class="line">333</div><div class="line">334</div><div class="line">335</div><div class="line">336</div><div class="line">337</div><div class="line">338</div><div class="line">339</div><div class="line">340</div><div class="line">341</div><div class="line">342</div><div class="line">343</div><div class="line">344</div><div class="line">345</div><div class="line">346</div><div class="line">347</div><div class="line">348</div><div class="line">349</div><div class="line">350</div><div class="line">351</div><div class="line">352</div><div class="line">353</div><div class="line">354</div><div class="line">355</div><div class="line">356</div><div class="line">357</div><div class="line">358</div><div class="line">359</div><div class="line">360</div><div class="line">361</div><div class="line">362</div><div class="line">363</div><div class="line">364</div><div class="line">365</div><div class="line">366</div><div class="line">367</div><div class="line">368</div><div class="line">369</div></pre></td><td class="code"><pre><div class="line"># ===================================================================</div><div class="line"># COMMON SPRING BOOT PROPERTIES</div><div class="line">#</div><div class="line"># This sample file is provided as a guideline. Do NOT copy it in its</div><div class="line"># entirety to your own application.               ^^^</div><div class="line"># ===================================================================</div><div class="line"></div><div class="line"># ----------------------------------------</div><div class="line"># CORE PROPERTIES</div><div class="line"># ----------------------------------------</div><div class="line"></div><div class="line"># SPRING CONFIG (ConfigFileApplicationListener)</div><div class="line">spring.config.name= # config file name (default to &apos;application&apos;)</div><div class="line">spring.config.location= # location of config file</div><div class="line"></div><div class="line"># PROFILES</div><div class="line">spring.profiles= # comma list of active profiles</div><div class="line"></div><div class="line"># APPLICATION SETTINGS (SpringApplication)</div><div class="line">spring.main.sources=</div><div class="line">spring.main.web-environment= # detect by default</div><div class="line">spring.main.show-banner=true</div><div class="line">spring.main....= # see class for all properties</div><div class="line"></div><div class="line"># LOGGING</div><div class="line">logging.path=/var/logs</div><div class="line">logging.file=myapp.log</div><div class="line">logging.config=</div><div class="line"></div><div class="line"># IDENTITY (ContextIdApplicationContextInitializer)</div><div class="line">spring.application.name=</div><div class="line">spring.application.index=</div><div class="line"></div><div class="line"># EMBEDDED SERVER CONFIGURATION (ServerProperties)</div><div class="line">server.port=8080</div><div class="line">server.address= # bind to a specific NIC</div><div class="line">server.session-timeout= # session timeout in seconds</div><div class="line">server.context-path= # the context path, defaults to &apos;/&apos;</div><div class="line">server.servlet-path= # the servlet path, defaults to &apos;/&apos;</div><div class="line">server.tomcat.access-log-pattern= # log pattern of the access log</div><div class="line">server.tomcat.access-log-enabled=false # is access logging enabled</div><div class="line">server.tomcat.protocol-header=x-forwarded-proto # ssl forward headers</div><div class="line">server.tomcat.remote-ip-header=x-forwarded-for</div><div class="line">server.tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)</div><div class="line">server.tomcat.background-processor-delay=30; # in seconds</div><div class="line">server.tomcat.max-threads = 0 # number of threads in protocol handler</div><div class="line">server.tomcat.uri-encoding = UTF-8 # character encoding to use for URL decoding</div><div class="line"></div><div class="line"># SPRING MVC (HttpMapperProperties)</div><div class="line">http.mappers.json-pretty-print=false # pretty print JSON</div><div class="line">http.mappers.json-sort-keys=false # sort keys</div><div class="line">spring.mvc.locale= # set fixed locale, e.g. en_UK</div><div class="line">spring.mvc.date-format= # set fixed date format, e.g. dd/MM/yyyy</div><div class="line">spring.mvc.message-codes-resolver-format= # PREFIX_ERROR_CODE / POSTFIX_ERROR_CODE</div><div class="line">spring.view.prefix= # MVC view prefix</div><div class="line">spring.view.suffix= # ... and suffix</div><div class="line">spring.resources.cache-period= # cache timeouts in headers sent to browser</div><div class="line">spring.resources.add-mappings=true # if default mappings should be added</div><div class="line"></div><div class="line"># THYMELEAF (ThymeleafAutoConfiguration)</div><div class="line">spring.thymeleaf.prefix=classpath:/templates/</div><div class="line">spring.thymeleaf.suffix=.html</div><div class="line">spring.thymeleaf.mode=HTML5</div><div class="line">spring.thymeleaf.encoding=UTF-8</div><div class="line">spring.thymeleaf.content-type=text/html # ;charset=&lt;encoding&gt; is added</div><div class="line">spring.thymeleaf.cache=true # set to false for hot refresh</div><div class="line"></div><div class="line"># FREEMARKER (FreeMarkerAutoConfiguration)</div><div class="line">spring.freemarker.allowRequestOverride=false</div><div class="line">spring.freemarker.allowSessionOverride=false</div><div class="line">spring.freemarker.cache=true</div><div class="line">spring.freemarker.checkTemplateLocation=true</div><div class="line">spring.freemarker.contentType=text/html</div><div class="line">spring.freemarker.exposeRequestAttributes=false</div><div class="line">spring.freemarker.exposeSessionAttributes=false</div><div class="line">spring.freemarker.exposeSpringMacroHelpers=false</div><div class="line">spring.freemarker.prefix=</div><div class="line">spring.freemarker.requestContextAttribute=</div><div class="line">spring.freemarker.settings.*=</div><div class="line">spring.freemarker.suffix=.ftl</div><div class="line">spring.freemarker.templateEncoding=UTF-8</div><div class="line">spring.freemarker.templateLoaderPath=classpath:/templates/</div><div class="line">spring.freemarker.viewNames= # whitelist of view names that can be resolved</div><div class="line"></div><div class="line"># GROOVY TEMPLATES (GroovyTemplateAutoConfiguration)</div><div class="line">spring.groovy.template.allowRequestOverride=false</div><div class="line">spring.groovy.template.allowSessionOverride=false</div><div class="line">spring.groovy.template.cache=true</div><div class="line">spring.groovy.template.configuration.*= # See Groovy&apos;s TemplateConfiguration</div><div class="line">spring.groovy.template.contentType=text/html</div><div class="line">spring.groovy.template.prefix=classpath:/templates/</div><div class="line">spring.groovy.template.suffix=.tpl</div><div class="line">spring.groovy.template.templateEncoding=UTF-8</div><div class="line">spring.groovy.template.viewNames= # whitelist of view names that can be resolved</div><div class="line"></div><div class="line"># VELOCITY TEMPLATES (VelocityAutoConfiguration)</div><div class="line">spring.velocity.allowRequestOverride=false</div><div class="line">spring.velocity.allowSessionOverride=false</div><div class="line">spring.velocity.cache=true</div><div class="line">spring.velocity.checkTemplateLocation=true</div><div class="line">spring.velocity.contentType=text/html</div><div class="line">spring.velocity.dateToolAttribute=</div><div class="line">spring.velocity.exposeRequestAttributes=false</div><div class="line">spring.velocity.exposeSessionAttributes=false</div><div class="line">spring.velocity.exposeSpringMacroHelpers=false</div><div class="line">spring.velocity.numberToolAttribute=</div><div class="line">spring.velocity.prefix=</div><div class="line">spring.velocity.properties.*=</div><div class="line">spring.velocity.requestContextAttribute=</div><div class="line">spring.velocity.resourceLoaderPath=classpath:/templates/</div><div class="line">spring.velocity.suffix=.vm</div><div class="line">spring.velocity.templateEncoding=UTF-8</div><div class="line">spring.velocity.viewNames= # whitelist of view names that can be resolved</div><div class="line"></div><div class="line"># INTERNATIONALIZATION (MessageSourceAutoConfiguration)</div><div class="line">spring.messages.basename=messages</div><div class="line">spring.messages.cacheSeconds=-1</div><div class="line">spring.messages.encoding=UTF-8</div><div class="line"></div><div class="line"></div><div class="line"># SECURITY (SecurityProperties)</div><div class="line">security.user.name=user # login username</div><div class="line">security.user.password= # login password</div><div class="line">security.user.role=USER # role assigned to the user</div><div class="line">security.require-ssl=false # advanced settings ...</div><div class="line">security.enable-csrf=false</div><div class="line">security.basic.enabled=true</div><div class="line">security.basic.realm=Spring</div><div class="line">security.basic.path= # /**</div><div class="line">security.headers.xss=false</div><div class="line">security.headers.cache=false</div><div class="line">security.headers.frame=false</div><div class="line">security.headers.contentType=false</div><div class="line">security.headers.hsts=all # none / domain / all</div><div class="line">security.sessions=stateless # always / never / if_required / stateless</div><div class="line">security.ignored=false</div><div class="line"></div><div class="line"># DATASOURCE (DataSourceAutoConfiguration &amp; DataSourceProperties)</div><div class="line">spring.datasource.name= # name of the data source</div><div class="line">spring.datasource.initialize=true # populate using data.sql</div><div class="line">spring.datasource.schema= # a schema (DDL) script resource reference</div><div class="line">spring.datasource.data= # a data (DML) script resource reference</div><div class="line">spring.datasource.platform= # the platform to use in the schema resource (schema-$&#123;platform&#125;.sql)</div><div class="line">spring.datasource.continueOnError=false # continue even if can&apos;t be initialized</div><div class="line">spring.datasource.separator=; # statement separator in SQL initialization scripts</div><div class="line">spring.datasource.driverClassName= # JDBC Settings...</div><div class="line">spring.datasource.url=</div><div class="line">spring.datasource.username=</div><div class="line">spring.datasource.password=</div><div class="line">spring.datasource.max-active=100 # Advanced configuration...</div><div class="line">spring.datasource.max-idle=8</div><div class="line">spring.datasource.min-idle=8</div><div class="line">spring.datasource.initial-size=10</div><div class="line">spring.datasource.validation-query=</div><div class="line">spring.datasource.test-on-borrow=false</div><div class="line">spring.datasource.test-on-return=false</div><div class="line">spring.datasource.test-while-idle=</div><div class="line">spring.datasource.time-between-eviction-runs-millis=</div><div class="line">spring.datasource.min-evictable-idle-time-millis=</div><div class="line">spring.datasource.max-wait-millis=</div><div class="line"></div><div class="line"># MONGODB (MongoProperties)</div><div class="line">spring.data.mongodb.host= # the db host</div><div class="line">spring.data.mongodb.port=27017 # the connection port (defaults to 27107)</div><div class="line">spring.data.mongodb.uri=mongodb://localhost/test # connection URL</div><div class="line">spring.data.mongo.repositories.enabled=true # if spring data repository support is enabled</div><div class="line"></div><div class="line"># JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration)</div><div class="line">spring.jpa.properties.*= # properties to set on the JPA connection</div><div class="line">spring.jpa.openInView=true</div><div class="line">spring.jpa.show-sql=true</div><div class="line">spring.jpa.database-platform=</div><div class="line">spring.jpa.database=</div><div class="line">spring.jpa.generate-ddl=false # ignored by Hibernate, might be useful for other vendors</div><div class="line">spring.jpa.hibernate.naming-strategy= # naming classname</div><div class="line">spring.jpa.hibernate.ddl-auto= # defaults to create-drop for embedded dbs</div><div class="line">spring.data.jpa.repositories.enabled=true # if spring data repository support is enabled</div><div class="line"></div><div class="line"># SOLR (SolrProperties&#125;)</div><div class="line">spring.data.solr.host=http://127.0.0.1:8983/solr</div><div class="line">spring.data.solr.zkHost=</div><div class="line">spring.data.solr.repositories.enabled=true # if spring data repository support is enabled</div><div class="line"></div><div class="line"># ELASTICSEARCH (ElasticsearchProperties&#125;)</div><div class="line">spring.data.elasticsearch.cluster-name= # The cluster name (defaults to elasticsearch)</div><div class="line">spring.data.elasticsearch.cluster-nodes= # The address(es) of the server node (comma-separated; if not specified starts a client node)</div><div class="line">spring.data.elasticsearch.local=true # if local mode should be used with client nodes</div><div class="line">spring.data.elasticsearch.repositories.enabled=true # if spring data repository support is enabled</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"># FLYWAY (FlywayProperties)</div><div class="line">flyway.locations=classpath:db/migrations # locations of migrations scripts</div><div class="line">flyway.schemas= # schemas to update</div><div class="line">flyway.initVersion= 1 # version to start migration</div><div class="line">flyway.prefix=V</div><div class="line">flyway.suffix=.sql</div><div class="line">flyway.enabled=true</div><div class="line">flyway.url= # JDBC url if you want Flyway to create its own DataSource</div><div class="line">flyway.user= # JDBC username if you want Flyway to create its own DataSource</div><div class="line">flyway.password= # JDBC password if you want Flyway to create its own DataSource</div><div class="line"></div><div class="line"># LIQUIBASE (LiquibaseProperties)</div><div class="line">liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml</div><div class="line">liquibase.contexts= # runtime contexts to use</div><div class="line">liquibase.default-schema= # default database schema to use</div><div class="line">liquibase.drop-first=false</div><div class="line">liquibase.enabled=true</div><div class="line"></div><div class="line"># JMX</div><div class="line">spring.jmx.enabled=true # Expose MBeans from Spring</div><div class="line"></div><div class="line"># RABBIT (RabbitProperties)</div><div class="line">spring.rabbitmq.host= # connection host</div><div class="line">spring.rabbitmq.port= # connection port</div><div class="line">spring.rabbitmq.addresses= # connection addresses (e.g. myhost:9999,otherhost:1111)</div><div class="line">spring.rabbitmq.username= # login user</div><div class="line">spring.rabbitmq.password= # login password</div><div class="line">spring.rabbitmq.virtualhost=</div><div class="line">spring.rabbitmq.dynamic=</div><div class="line"></div><div class="line"># REDIS (RedisProperties)</div><div class="line">spring.redis.host=localhost # server host</div><div class="line">spring.redis.password= # server password</div><div class="line">spring.redis.port=6379 # connection port</div><div class="line">spring.redis.pool.max-idle=8 # pool settings ...</div><div class="line">spring.redis.pool.min-idle=0</div><div class="line">spring.redis.pool.max-active=8</div><div class="line">spring.redis.pool.max-wait=-1</div><div class="line"></div><div class="line"># ACTIVEMQ (ActiveMQProperties)</div><div class="line">spring.activemq.broker-url=tcp://localhost:61616 # connection URL</div><div class="line">spring.activemq.user=</div><div class="line">spring.activemq.password=</div><div class="line">spring.activemq.in-memory=true # broker kind to create if no broker-url is specified</div><div class="line">spring.activemq.pooled=false</div><div class="line"></div><div class="line"># HornetQ (HornetQProperties)</div><div class="line">spring.hornetq.mode= # connection mode (native, embedded)</div><div class="line">spring.hornetq.host=localhost # hornetQ host (native mode)</div><div class="line">spring.hornetq.port=5445 # hornetQ port (native mode)</div><div class="line">spring.hornetq.embedded.enabled=true # if the embedded server is enabled (needs hornetq-jms-server.jar)</div><div class="line">spring.hornetq.embedded.serverId= # auto-generated id of the embedded server (integer)</div><div class="line">spring.hornetq.embedded.persistent=false # message persistence</div><div class="line">spring.hornetq.embedded.data-directory= # location of data content (when persistence is enabled)</div><div class="line">spring.hornetq.embedded.queues= # comma separate queues to create on startup</div><div class="line">spring.hornetq.embedded.topics= # comma separate topics to create on startup</div><div class="line">spring.hornetq.embedded.cluster-password= # customer password (randomly generated by default)</div><div class="line"></div><div class="line"># JMS (JmsProperties)</div><div class="line">spring.jms.pub-sub-domain= # false for queue (default), true for topic</div><div class="line"></div><div class="line"># SPRING BATCH (BatchDatabaseInitializer)</div><div class="line">spring.batch.job.names=job1,job2</div><div class="line">spring.batch.job.enabled=true</div><div class="line">spring.batch.initializer.enabled=true</div><div class="line">spring.batch.schema= # batch schema to load</div><div class="line"></div><div class="line"># AOP</div><div class="line">spring.aop.auto=</div><div class="line">spring.aop.proxy-target-class=</div><div class="line"></div><div class="line"># FILE ENCODING (FileEncodingApplicationListener)</div><div class="line">spring.mandatory-file-encoding=false</div><div class="line"></div><div class="line"># SPRING SOCIAL (SocialWebAutoConfiguration)</div><div class="line">spring.social.auto-connection-views=true # Set to true for default connection views or false if you provide your own</div><div class="line"></div><div class="line"># SPRING SOCIAL FACEBOOK (FacebookAutoConfiguration)</div><div class="line">spring.social.facebook.app-id= # your application&apos;s Facebook App ID</div><div class="line">spring.social.facebook.app-secret= # your application&apos;s Facebook App Secret</div><div class="line"></div><div class="line"># SPRING SOCIAL LINKEDIN (LinkedInAutoConfiguration)</div><div class="line">spring.social.linkedin.app-id= # your application&apos;s LinkedIn App ID</div><div class="line">spring.social.linkedin.app-secret= # your application&apos;s LinkedIn App Secret</div><div class="line"></div><div class="line"># SPRING SOCIAL TWITTER (TwitterAutoConfiguration)</div><div class="line">spring.social.twitter.app-id= # your application&apos;s Twitter App ID</div><div class="line">spring.social.twitter.app-secret= # your application&apos;s Twitter App Secret</div><div class="line"></div><div class="line"># SPRING MOBILE SITE PREFERENCE (SitePreferenceAutoConfiguration)</div><div class="line">spring.mobile.sitepreference.enabled=true # enabled by default</div><div class="line"></div><div class="line"># SPRING MOBILE DEVICE VIEWS (DeviceDelegatingViewResolverAutoConfiguration)</div><div class="line">spring.mobile.devicedelegatingviewresolver.enabled=true # disabled by default</div><div class="line">spring.mobile.devicedelegatingviewresolver.normalPrefix=</div><div class="line">spring.mobile.devicedelegatingviewresolver.normalSuffix=</div><div class="line">spring.mobile.devicedelegatingviewresolver.mobilePrefix=mobile/</div><div class="line">spring.mobile.devicedelegatingviewresolver.mobileSuffix=</div><div class="line">spring.mobile.devicedelegatingviewresolver.tabletPrefix=tablet/</div><div class="line">spring.mobile.devicedelegatingviewresolver.tabletSuffix=</div><div class="line"></div><div class="line"># ----------------------------------------</div><div class="line"># ACTUATOR PROPERTIES</div><div class="line"># ----------------------------------------</div><div class="line"></div><div class="line"># MANAGEMENT HTTP SERVER (ManagementServerProperties)</div><div class="line">management.port= # defaults to &apos;server.port&apos;</div><div class="line">management.address= # bind to a specific NIC</div><div class="line">management.contextPath= # default to &apos;/&apos;</div><div class="line"></div><div class="line"># ENDPOINTS (AbstractEndpoint subclasses)</div><div class="line">endpoints.autoconfig.id=autoconfig</div><div class="line">endpoints.autoconfig.sensitive=true</div><div class="line">endpoints.autoconfig.enabled=true</div><div class="line">endpoints.beans.id=beans</div><div class="line">endpoints.beans.sensitive=true</div><div class="line">endpoints.beans.enabled=true</div><div class="line">endpoints.configprops.id=configprops</div><div class="line">endpoints.configprops.sensitive=true</div><div class="line">endpoints.configprops.enabled=true</div><div class="line">endpoints.configprops.keys-to-sanitize=password,secret</div><div class="line">endpoints.dump.id=dump</div><div class="line">endpoints.dump.sensitive=true</div><div class="line">endpoints.dump.enabled=true</div><div class="line">endpoints.env.id=env</div><div class="line">endpoints.env.sensitive=true</div><div class="line">endpoints.env.enabled=true</div><div class="line">endpoints.health.id=health</div><div class="line">endpoints.health.sensitive=false</div><div class="line">endpoints.health.enabled=true</div><div class="line">endpoints.info.id=info</div><div class="line">endpoints.info.sensitive=false</div><div class="line">endpoints.info.enabled=true</div><div class="line">endpoints.metrics.id=metrics</div><div class="line">endpoints.metrics.sensitive=true</div><div class="line">endpoints.metrics.enabled=true</div><div class="line">endpoints.shutdown.id=shutdown</div><div class="line">endpoints.shutdown.sensitive=true</div><div class="line">endpoints.shutdown.enabled=false</div><div class="line">endpoints.trace.id=trace</div><div class="line">endpoints.trace.sensitive=true</div><div class="line">endpoints.trace.enabled=true</div><div class="line"></div><div class="line"># MVC ONLY ENDPOINTS</div><div class="line">endpoints.jolokia.path=jolokia</div><div class="line">endpoints.jolokia.sensitive=true</div><div class="line">endpoints.jolokia.enabled=true # when using Jolokia</div><div class="line">endpoints.error.path=/error</div><div class="line"></div><div class="line"># JMX ENDPOINT (EndpointMBeanExportProperties)</div><div class="line">endpoints.jmx.enabled=true</div><div class="line">endpoints.jmx.domain= # the JMX domain, defaults to &apos;org.springboot&apos;</div><div class="line">endpoints.jmx.unique-names=false</div><div class="line">endpoints.jmx.enabled=true</div><div class="line">endpoints.jmx.staticNames=</div><div class="line"></div><div class="line"># JOLOKIA (JolokiaProperties)</div><div class="line">jolokia.config.*= # See Jolokia manual</div><div class="line"></div><div class="line"># REMOTE SHELL</div><div class="line">shell.auth=simple # jaas, key, simple, spring</div><div class="line">shell.command-refresh-interval=-1</div><div class="line">shell.command-path-pattern= # classpath*:/commands/**, classpath*:/crash/commands/**</div><div class="line">shell.config-path-patterns= # classpath*:/crash/*</div><div class="line">shell.disabled-plugins=false # don&apos;t expose plugins</div><div class="line">shell.ssh.enabled= # ssh settings ...</div><div class="line">shell.ssh.keyPath=</div><div class="line">shell.ssh.port=</div><div class="line">shell.telnet.enabled= # telnet settings ...</div><div class="line">shell.telnet.port=</div><div class="line">shell.auth.jaas.domain= # authentication settings ...</div><div class="line">shell.auth.key.path=</div><div class="line">shell.auth.simple.user.name=</div><div class="line">shell.auth.simple.user.password=</div><div class="line">shell.auth.spring.roles=</div><div class="line"></div><div class="line"># GIT INFO</div><div class="line">spring.git.properties= # resource ref to generated git info properties file</div></pre></td></tr></table></figure>
                
<p class="red-link-context">
    <a href="/2017/07/06/SpringBoot之Mybatis手写分页组件/" rel="next" title="SpringBoot之Mybatis手写分页组件">
    上一篇：SpringBoot之Mybatis手写分页组件
  </a>
</p>



<p class="red-link-context">
    <a href="/2017/07/06/Spring Boot系列之Hello World/" rel="next" title="Spring Boot系列之Hello World">
    下一篇：Spring Boot系列之Hello World
  </a>
</p>


            </div>
			
        </div>
    </div>
</article>




    <section id="comment">
        <div class="card">
            <div class="card-content">
                <!-- Duoshuo Comment BEGIN -->
                <div class="ds-thread" data-thread-key="2017/07/06/SpringBoot通过JPA链接数据库及配置文件相关/" data-title="SpringBoot通过JPA链接数据库及配置文件相关" data-url="http://dengzy007hi.oschina.io/2017/07/06/SpringBoot通过JPA链接数据库及配置文件相关/"></div>

                <script type="text/javascript">
                    console.log(document.querySelector('.ds-thread'));
                    var duoshuoQuery = {
                        short_name: 'dengzy007hi'
                    };
                    (function() {
                        var ds = document.createElement('script');
                        ds.type = 'text/javascript';
                        ds.async = true;
                        ds.src = (document.location.protocol == 'https:'
                            ? 'https:'
                            : 'http:') + '//static.duoshuo.com/embed.js';
                        ds.charset = 'UTF-8';
                        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds);
                    })();
                </script>
                <!-- Duoshuo Comment END -->
            </div>
        </div>
    </section>



</div>

        <div class="fixed-action-btn float-sitemap">
    <a class="btn-floating btn-large red">
      <i class="fa fa-caret-square-o-up"></i>
    </a>
    <ul>
      <li><a class="btn-return-top btn-floating waves-effect cyan" title="回到顶部"><i class="fa fa-arrow-circle-o-up"></i></a></li>
      <li><a class="btn-floating waves-effect button-collapse light-green"  data-activates="main-menu" title="menu"><i class="fa fa-navicon"></i></a></li>
    </ul>
  </div>

    </main>
    <footer class="page-footer green darken-1">
    
    <div class="container">
        <div class="row">
            
            <div class="social-group col m4 s12">
                <h5 class="white-text">社交</h5>
                
                    <a class="social-link" href="http://weibo.com/bambooJN" target="_blank">
                        <i class="fa fa-2x fa-weibo"></i>
                    </a>
                
                    <a class="social-link" href="https://git.oschina.net/dengzy007hi" target="_blank">
                        <i class="fa fa-2x fa-github"></i>
                    </a>
                
                    <a class="social-link" href="/atom.xml" target="_blank">
                        <i class="fa fa-2x fa-rss"></i>
                    </a>
                
                <div class="site-visitors-container white-text">
                    <span>
                        <i class="fa fa-user"></i>
                        <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
                    </span>
                    <span>&nbsp;|&nbsp;</span>
                    <span>
                        <i class="fa fa-eye"></i>
                        <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
                    </span>
                </div>
            </div>
            

            
            <div class="col m8 s12">
                <h5 class="white-text">友情链接</h5>
                
                    <a class="social-link" href="https://www.oschina.net" target="_blank">开源中国</a>
                
                    <a class="social-link" href="http://jdkleo.iteye.com/" target="_blank">JDKLEO</a>
                
                    <a class="social-link" href="http://pkaq.org/" target="_blank">如是我闻</a>
                
            </div>
            
        </div>
    </div>
    

    <div class="footer-copyright red-link-context">
        <div class="container">
            © 2017 dzy20@qq.com, All rights reserved.
            <p class="right" style="margin-top: 0;">本博客由 <a href="https://hexo.io">Hexo</a> 强力驱动 | 主题 <a href="https://github.com/raytaylorlin/hexo-theme-raytaylorism">raytaylorism</a></p>
        </div>
    </div>
</footer>


    <noscript>
    <div class="noscript">
        <p class="center-align">当前网速较慢或者你使用的浏览器不支持博客特定功能，请尝试刷新或换用Chrome、Firefox等现代浏览器</p>
    </div>
</noscript>
<div class="noscript">
    <p class="center-align">当前网速较慢或者你使用的浏览器不支持博客特定功能，请尝试刷新或换用Chrome、Firefox等现代浏览器</p>
</div>


<script src="/js/jquery.min.js"></script>
<script src="/js/materialize.min.js"></script>
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<script>
    (function($) {
        $(document).ready(function() {
            // 隐藏禁用javascript（针对微信内置浏览器）的提示
            $('.noscript').hide();

            // 图片缩放效果
            var $imgs = $('img').not('.slider-image').not('.avatar-image').not('.carousel-image').not('.card-cover-image').not('.qrcode');

            // 给图片加上点击放大效果（materialbox插件）
            $imgs.addClass('materialboxed').each(function(i, el) {
                $(this).attr('data-caption', $(this).attr('alt') || ' ');
            }).materialbox();

            // 优化表格的显示
            $('table').each(function() {
                var $table = $(this);
                // 除去多行代码的情况
                if ($table.find('pre').length == 0) {
                    $table.addClass('responsive-table striped bordered');
                }
            });

            // 首页幻灯片
            $('.slider').slider({indicators: true, full_width: true, interval: 8000});

            $(".button-collapse").sideNav();
            $(".category-menu").sideNav();

            // 针对gallery post
            $('.carousel').carousel({full_width: true});
            $('.carousel-control.prev').click(function() {
                $('.carousel').carousel('prev');
            });
            $('.carousel-control.next').click(function() {
                $('.carousel').carousel('next');
            });

            // 文章目录
            $('article').not('.simple-article').find('h1').add('h2').add('h3').add('h4').add('h5').add('h6').scrollSpy();

            // 目录随屏幕滚动（防止目录过长越过footer）
            var $toc = $('.toc');
            var scrollTargetTop = 0;
            $(window).scroll(function() {
                var $activeLink = $toc.find('a.active.section');
                if ($(window).scrollTop() < 100) {
                    scrollTargetTop = 0;
                } else {
                    if ($activeLink[0]) {
                        scrollTargetTop = $activeLink.offset().top - $toc.offset().top;
                    }
                }
                $toc.css('top', '-' + scrollTargetTop + 'px');
            });

            // 修正文章目录的left-border颜色
            var color = $('.table-of-contents-text').css('color');
            $('.table-of-contents-link').css('border-left-color', color);

            // 针对移动端做的优化：FAB按钮点击一下收回
            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                $('.fixed-action-btn').addClass('click-to-toggle');
            }
            // 回到顶部
            $('.btn-return-top').click(function() {
                $('body, html').animate({
                    scrollTop: 0
                }, 500);
            });

            // 重置读书页面的Tab标签页的颜色
            $('li.tab a').hover(function() {
                $(this).toggleClass('text-lighten-4');
            });
            $('.indicator').addClass('red lighten-2');

            
            // 添加new标签
            $('.menu-about').append('<span class="new badge red"></span>');
            

            // 搜索功能
            $('.modal-trigger').leanModal({
                // 打开搜索框时自动聚焦
                ready: function() {
                    if ($('#search').is(":visible")) {
                        $('#search-input').focus();
                    }
                }
            });
            var searchXml = "search.xml";
            if (searchXml.length == 0) {
             	searchXml = "search.xml";
            }
            var searchPath = "/" + searchXml;
            initSearch(searchPath, 'search-input', 'search-result');
        });

        // 初始化搜索与匹配函数
        var initSearch = function(path, search_id, content_id) {
            'use strict';
            $.ajax({
                url: path,
                dataType: "xml",
                success: function(xmlResponse) {
                    // get the contents from search data
                    var datas = $("entry", xmlResponse).map(function() {
                        return {
                            title: $("title", this).text(),
                            content: $("content", this).text(),
                            url: $("url", this).text()
                        };
                    }).get();
                    var $input = document.getElementById(search_id);
                    var $resultContent = document.getElementById(content_id);
                    $input.addEventListener('input', function() {
                        var str = '<ul class=\"search-result-list\">';
                        var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                        $resultContent.innerHTML = "";
                        if (this.value.trim().length <= 0) {
                            return;
                        }
                        // perform local searching
                        datas.forEach(function(data) {
                            var isMatch = true;
                            var content_index = [];
                            var data_title = data.title.trim().toLowerCase();
                            var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                            var data_url = data.url;
                            var index_title = -1;
                            var index_content = -1;
                            var first_occur = -1;
                            // only match artiles with not empty titles and contents
                            if (data_title != '' && data_content != '') {
                                keywords.forEach(function(keyword, i) {
                                    index_title = data_title.indexOf(keyword);
                                    index_content = data_content.indexOf(keyword);
                                    if (index_title < 0 && index_content < 0) {
                                        isMatch = false;
                                    } else {
                                        if (index_content < 0) {
                                            index_content = 0;
                                        }
                                        if (i == 0) {
                                            first_occur = index_content;
                                        }
                                    }
                                });
                            }
                            // show search results
                            if (isMatch) {
                                keywords.forEach(function(keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    data_title = data_title.replace(regS, "<span class=\"search-keyword red lighten-2\">" + keyword + "</span>");
                                });

                                str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                                var content = data.content.trim().replace(/<[^>]+>/g, "");
                                if (first_occur >= 0) {
                                    // cut out 100 characters
                                    var start = first_occur - 20;
                                    var end = first_occur + 80;
                                    if (start < 0) {
                                        start = 0;
                                    }
                                    if (start == 0) {
                                        end = 100;
                                    }
                                    if (end > content.length) {
                                        end = content.length;
                                    }
                                    var match_content = content.substring(start, end);
                                    // highlight all keywords
                                    keywords.forEach(function(keyword) {
                                        var regS = new RegExp(keyword, "gi");
                                        match_content = match_content.replace(regS, "<span class=\"search-keyword red lighten-2\">" + keyword + "</span>");
                                    });

                                    str += "<p class=\"search-result\">..." + match_content + "...</p>"
                                }
                                str += "</li>";
                            }
                        });
                        str += "</ul>";
                        $resultContent.innerHTML = str;
                    });
                }
            });
        }
    })(jQuery);
</script>


<script src="/js/prettify.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("pre").addClass("prettyprint");
        prettyPrint();
    });
</script>








</body>
</html>
